package com.sunriz.motordrive.controller.photovoltaic;

import com.sunriz.motordrive.domain.DTO.SetValueDTO;
import com.sunriz.motordrive.domain.DTO.Result;
import com.sunriz.motordrive.server.photoVoltaic.PhotovoltaicHcServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * ClassName: PhotoVolaticHc
 * Package: com.sunriz.motordrive.controller.photoVolatic.hc
 * Description:
 *
 * @Author BuTang
 * @Create 2024/7/2 11:41
 * @Version 1.0
 */

@Slf4j
@RestController
@RequestMapping("/photoVoltaic")
public class PhotovoltaicHcController {
    @Autowired
    PhotovoltaicHcServer photoVoltaicHc;


    @GetMapping("/timed/getRead")
    public Result getOnlyReadData(){
        return photoVoltaicHc.getOnlyReadData();
    }

    @GetMapping("/timed/getReadAndWrite")
    public Result getReadAndWrite(){
        return photoVoltaicHc.getReadAndWrite();
    }

    @CrossOrigin
    @PutMapping("/hc/setMotorStatus")
    public Result setMotorStatus(@RequestBody SetValueDTO setValueDTO){
        return photoVoltaicHc.setMotorStatus(setValueDTO);
    }


    @GetMapping("/timed/getData")
    public Result getData(){
        return photoVoltaicHc.getData();
    }

    /**
     * demo 下发数据
     * todo 记得删除 无用
     * @return
     */
    @GetMapping("/updateVersion")
    public Result updateVersion(){

        return photoVoltaicHc.updateVersionDemo();
    }

    @PostMapping("/hc/uploadFile")
    public Result uploadFile(@RequestParam MultipartFile file) {
        return photoVoltaicHc.updateVersion(file);
    }




}
